<template>
	<view class="base">
		<scroll-view scroll-y="" class="invoice-all">
			<view class="noData" v-if="JSON.stringify(dataList)=='[]'">
				暂未申请开票
			</view>

			<view v-for="(item,index) in dataList" :key="index">
				<view class="invoice-item" @click="invoiceDetail(item)">
					<view class="invoice-item-top">开票成功</view>
					<view class="invoice-item-data">
						<view class="name">
							开票用户
						</view>
						<view class="data">
							{{item.updateBy}}
						</view>
					</view>
					<view class="invoice-item-data">
						<view class="name">
							申请时间
						</view>
						<view class="data">
							{{item.updateTime}}
						</view>
					</view>
					<view class="invoice-item-data">
						<view class="name">
							发票金额
						</view>
						<view class="data">
							￥{{item.totalPrice}}
						</view>
					</view>
					<view class="invoice-item-data">
						<view class="name">
							发票类型
						</view>
						<view class="data">
							电子发票
						</view>
					</view>
				</view>

			</view>
		</scroll-view>

		<button class="addInvoice" @click="onAllOrder">新建 +</button>
	</view>
</template>

<script>
	import {
		allBill
	} from '@/api/system/order.js'
	export default {
		data() {
			return {
				dataList: ''
			};
		},
		methods: {
			onAllOrder() {
				this.$tab.navigateTo('../orderManagement/allOrder')
			},
			invoiceDetail(item) {
				this.$tab.navigateTo('./orderNumber?data=' + JSON.stringify(item))
			},
			getInvoice() {
				this.$modal.loading('加载中')
				allBill().then(res => {
					if (res.code == 200) {
						if (res.data.length == 0) return this.dataList = []
						this.dataList = res.data
					} else {
						this.$modal.msgError(res.msg)
					}
					this.$modal.closeLoading()
				})
			}
		},
		onLoad() {
			this.getInvoice()
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #65A8F2;
		margin: 0;
		padding: 0;
	}

	.noData {
		text-align: center;
		margin: 60rpx;
		font-weight: 600;
		font-size: 40rpx;
		color: #ccc;
	}

	.base {
		width: 680rpx;
		margin: auto;
	}

	.invoice-all {
		margin-top: 20rpx;
		height: 800rpx;

		.invoice-item {
			width: 100%;
			height: 350rpx;
			border-radius: 20rpx;
			background-color: rgba(255, 255, 255, 1);
			border: 1px solid rgba(187, 187, 187, 1);
			margin-bottom: 20rpx;


			.invoice-item-top {
				width: 100%;
				height: 60rpx;
				line-height: 60rpx;
				padding-right: 30rpx;
				text-align: right;
				color: rgba(79, 141, 247, 1);
				font-size: 32rpx;
				border: 2rpx dashed #ccc;

			}

			.invoice-item-data {
				display: flex;
				justify-content: space-between;
				height: 70rpx;
				color: rgba(16, 16, 16, 1);
				font-size: 36rpx;
				line-height: 70rpx;
				padding: 0 20rpx;

			}
		}
	}

	.addInvoice {
		width: 540rpx;
		height: 90rpx;
		border-radius: 20rpx;
		background-color: rgba(255, 255, 255, 1);
		margin-top: 160rpx;
		color: rgba(144, 141, 141, 1);
		font-size: 40rpx;
		box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.4);
	}
</style>
